import wx

# Ids


class CheckBoxFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Export Sequences', size=(500, 700))
        self.panel = wx.Panel(self, -1)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.panel.sizer = wx.GridBagSizer(hgap=5, vgap=5)

        # Check boxes per hit

        data =['TA000703', 'TA000704']
        row = 2
        for lable in data:
            self.make_widgets(lable, row, id=row)
            row += 1


        # Check boxes for db entries
#        db_entries = ["pIPKTA ID", "Tube ID", "Corrected ID", "GABI Phenom ID",
#                  "Construct function", "Vector", "Plate", "Position",
#                  "Longest Sequence", "RNAi Sequence", "Primer Left", "Primer Right"]

        db_entries = ["pIPKTA ID", "Tube ID", "Construct Function", "Gus cells",
                  "Haustoria", "SI, %, Log2?", "Experiment Name", "Cultivar Name", "Hours after inoculation",
                  "Pathogen Name"]

        row = len(data)+4
        for lable in db_entries:
            self.make_widgets(lable, row, id=row)
            row += 1

        # Check boxes for output formats
        formats = ["Seperate Fasta File", "Multiple Fasta File", "Seperate CSV File",
                  "Multiple CSV File"]

        row = len(data) + len(db_entries) + 6
        for lable in formats:
            self.make_widgets(lable, row, id=row)
            row += 1

        # Rest
        # Add request limit and button
        text = wx.StaticText(self.panel, -1, "Please choose a hit:", (8, 10))
        text2 = wx.StaticText(self.panel, -1, "Please choose a database entry:", (8, 10))
        text3 = wx.StaticText(self.panel, -1, "Please choose an output format:", (8, 10))

        #button = AB.AquaButton(self.panel, -1,None, "Start Request", size=(120,50))
        #self.Bind(wx.EVT_BUTTON, self.change_tab_event)

        text.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))
        text2.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))
        text3.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))

        #button.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))

        self.panel.sizer.Add(text, pos=(1, 3))
        self.panel.sizer.Add(text2, pos=(len(data)+3, 3))
        self.panel.sizer.Add(text3, pos=(len(data)+ len(db_entries)+ 5, 3))
        #self.panel.sizer.Add(button, pos=(11, 2))

        mainSizer.Add(self.panel.sizer, 0, wx.ALL, 10)
        self.panel.SetSizer(mainSizer)
        mainSizer.Fit(self.panel)
        mainSizer.SetSizeHints(self.panel)

    def EvtCheckBox(self, evt):
        # CB conditions
        cb_single_fas = self.panel.FindWindowByLabel("Seperate Fasta File")
        cb_multi_fas = self.panel.FindWindowByLabel("Multiple Fasta File")
        cb_single_csv = self.panel.FindWindowByLabel("Seperate CSV File")
        cb_multi_csv = self.panel.FindWindowByLabel("Multiple CSV File")

        if cb_single_fas.GetValue() == True:
            #print 'single true'
            cb_multi_fas.Enable(False)
            cb_single_csv.Enable(False)
            cb_multi_csv.Enable(False)
        elif cb_single_fas.GetValue() == False:
            #print 'single false'
            cb_multi_fas.Enable(True)
            cb_single_csv.Enable(True)
            cb_multi_csv.Enable(True)
        if cb_single_csv.GetValue() == True:
            #print 'single true'
            cb_multi_fas.Enable(False)
            cb_single_fas.Enable(False)
            cb_multi_csv.Enable(False)
        elif cb_single_csv.GetValue() == False:
            #print 'single false'
            cb_multi_fas.Enable(True)
            cb_single_fas.Enable(True)
            cb_multi_csv.Enable(True)
#        if cb_multi_fas.GetValue() == True:
#            #print 'multi true'
#            cb_single_fas.Enable(False)
#            cb_single_csv.Enable(False)
#            cb_multi_csv.Enable(False)
#        if cb_multi_fas.GetValue() == False:
#            #print 'multip false'
#            cb_single_fas.Enable(True)
#            cb_single_csv.Enable(True)
#            cb_multi_csv.Enable(True)

    def make_widgets(self, lable, row, id):
        """Function to create text anc cb widgets."""
        # Widgets
        cb = wx.CheckBox(self.panel, id, lable, (90, 50), (-1, -1))
        self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb)

        # Fonts
        cb.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))
        # Sizers
        self.panel.sizer.Add(cb, pos=(row, 3))


if __name__ == '__main__':
    app = wx.PySimpleApp()
    CheckBoxFrame().Show()
    app.MainLoop()